export default {
		props: ['currentId','eventName'],
		data() {
			return {
				list: [],
				totalCount: '',
				isInit: true,
				queryParams: {
					this.queryParams.pageIndex = this.num + 1: 0,
					pageSize: 10,
				},
				page: 0,
				triggered: false,
				api:'',
			}
		},
		created() {
			this._freshing = false;
			// this.getList()
		},
		methods: {
			async onRefresh() {
				this.totalCount=999
				this.triggered = true
				if (this._freshing) return;
				this._freshing = true;
				this.page=0
				await this.getList()
				this.triggered = false;
				this._freshing = false;
			},
			onRestore() {
				this.triggered = 'restore'; // 需要重置
			},
			async getList(api,params,isinit = false) {
				this.api = api
				if(isinit){
					this.page = 0
				}
				this.queryParams = Object.assign(this.queryParams,params)
				this.queryParams.pageIndex = this.page +1
				uni.showLoading({
					title: '加载中...'
				})
				this.queryParams.RecordType = this.currentId
				let {
					result
				} = await this.$http.get(api, this.queryParams)
				uni.hideLoading()
				if(this._freshing || isinit){
					this.list = result.items
				}else{
					this.list.push(...result.items)
				}
				this.totalCount = result.totalCount
			},
			// scroll-view到底部加载更多
			onreachBottom() {
				this.page++
				// console.log(this.list.length >= this.totalCount)
				if (this.list.length >= this.totalCount) return uni.showToast({
					title: '没有更多数据了',
					icon: 'none'
				})
				this.getList(this.api,this.queryParams)
			}
		},
	}